find the nth term given two terms